<template>
	<div>
		<el-row>
			<el-col class="num" :span="12">
				<span>
					<h2 style="font-size:25px ;">未就诊患者</h2>
				</span>
				<el-divider style="width: 10;"></el-divider>
			</el-col>
			<el-col class="num" :span="12">
				<span>
					<h2>已就诊患者</h2>
				</span>
				<el-divider></el-divider>
			</el-col>
		</el-row>
		<el-form :model="notform">
			<el-row>
				<el-col class="num" :span="5">
					<el-form-item prop="dcotor">
						<el-input v-model="notform.doctor" placeholder="请输入医生姓名" style="width: 10;"></el-input>
					</el-form-item>
				</el-col>

				<el-col class="num" :span="4" offset="1">
					<el-form-item>
						<el-button type="primary" @click="getdoctorpaitient()">叫号</el-button>
					</el-form-item>
				</el-col>
			</el-row>
		</el-form>
		<el-row>
			<el-col :span="10">
				<el-table :data="notpatient" max-height="800px" border style="width: 100%;background-color: #ddf3ff;">
					<el-table-column prop="idnumber" label="就诊卡ID" width="135">
					</el-table-column>
					<el-table-column prop="name" label="姓名" width="135">
					</el-table-column>
					<el-table-column prop="state" label="就诊状态" width="135">
					</el-table-column>
					<el-table-column prop="" label="操作">
						<template slot-scope="scope">
							<el-button @click="update(scope.$index,notpatient)">看诊</el-button>
						</template>
					</el-table-column>
				</el-table>
			</el-col>
			<el-col :span="2"></el-col>
			<el-col :span="12" offset="2">
				<el-table :data="alreadypatient" max-height="800px" border
					style="width: 100%;background-color: #ddf3ff;">
					<el-table-column prop="idnumber" label="就诊卡ID" width="180">
					</el-table-column>
					<el-table-column prop="name" label="姓名" width="180">
					</el-table-column>
					<el-table-column prop="state" label="就诊状态">
					</el-table-column>
				</el-table>
			</el-col>
		</el-row>
	</div>
</template>

<script>
	import {
		showMsgTitle
	} from '@/utils/api'
	import {
		showMsgConfirm
	} from '@/utils/api'
	import {
		getRequest
	} from '@/utils/api'
	import {
		postRequest
	} from '@/utils/api'
	import {
		uploadFileRequest
	} from '@/utils/api'
	import {
		putRequest
	} from '@/utils/api'
	import {
		deleteRequest
	} from '@/utils/api'
	import {
		showConstants
	} from '@/utils/api'
	export default {
		data() {
			return {

				alreadypatient: [],
				notpatient: [],
				notform: []
			}
		},
		methods: {
			getdoctorpaitient() {
				this.$axios.get('http://localhost:8081/notregister?doctor=' + this.notform.doctor).then((result) => {
					console.log(result.data);
					this.notpatient = result.data
				}).catch((err) => {
					console.log(error);
				});
				this.$axios.get('http://localhost:8081/alregister?doctor=' + this.notform.doctor).then((result) => {
					console.log(result.data);
					this.alreadypatient = result.data
				}).catch((err) => {
					console.log(error);
				});
			},
			update(index, rows) {
				postRequest('/upregister?idnumber=' + this.notpatient[index].idnumber).then(resp => {
					this.$router.push('/main2/doctor');
				})
			}

		},

		mounted: function() {
			let url1 = "/alregister";
			let url2 = "/notregister";
			let _this = this;
			getRequest(url1).then(
				resp => {
					if (resp.status == 200) {
						//        	alert(resp.data);
						_this.menus = resp.data;
					} else {
						_this.$message({
							type: 'error',
							message: '非200数据加载失败!'
						});
					}
				},
				resp => {
					_this.loading = false;
					if (resp.response.status == 403) {
						_this.$message({
							type: 'error',
							message: resp.response.data
						});
					} else {
						_this.$message({
							type: 'error',
							message: '500数据加载失败!'
						});
					}
				}
			).catch(resp => {
				//压根没见到服务器
				_this.loading = false;
				_this.$message({
					type: 'error',
					message: '404数据加载失败!'
				});
			});
			getRequest(url2).then(
				resp => {
					if (resp.status == 200) {
						//        	alert(resp.data);
						_this.menus = resp.data;
					} else {
						_this.$message({
							type: 'error',
							message: '非200数据加载失败!'
						});
					}
				},
				resp => {
					_this.loading = false;
					if (resp.response.status == 403) {
						_this.$message({
							type: 'error',
							message: resp.response.data
						});
					} else {
						_this.$message({
							type: 'error',
							message: '500数据加载失败!'
						});
					}
				}
			).catch(resp => {
				//压根没见到服务器
				_this.loading = false;
				_this.$message({
					type: 'error',
					message: '404数据加载失败!'
				});
			});
		},
		mounted() {
			this.getajson()
		},
	}
</script>

<style>
	.num.el-col {
		background-color: #FFFFFF;
	}
</style>
